//
//  HotCityTableViewCell.m
//  OCUI
//
//  Created by login on 15-7-20.
//
//

#import "HotCityTableViewCell.h"

@implementation HotCityTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier WithButtonTitle:(NSArray *)array
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        CGFloat width = [UIScreen mainScreen].bounds.size.width;
        CGFloat edge = 20;
        CGFloat buttonWidth = (width-4*edge)/3;
        int buttonTitle = 0;
        
        for (int i = 0; i<3; i++) {
            for (int j = 0; j<3; j++) {
                
                UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(edge + (buttonWidth + edge)*j, 5 + (40 + 10)*i , buttonWidth , 40)];
            
                button.backgroundColor = [UIColor lightGrayColor];
                [button.layer setCornerRadius:5];
                button.titleLabel.textColor = [UIColor blackColor];
                [button setTitle:array[buttonTitle] forState:UIControlStateNormal];
                [self.contentView addSubview:button];
                [button addTarget:self action:@selector(buttonTitle:) forControlEvents:UIControlEventTouchUpInside];
                buttonTitle ++;

            }
        }
        
    }
    return self;
}

- (void)buttonTitle:(UIButton *)button
{
    [self.delegate getClickedButtonTitle:button.titleLabel.text];
}

+ (CGFloat)getCellHeight
{
    CGFloat height;
    height += 5;
    height += 40;
    height += 10;
    height += 40;
    height += 10;
    height += 40;
    height += 5;

    return height;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
